import 'dart:async';


import 'package:flutter/services.dart';
import '../pages/gmap/gmapHelper.dart';
import '../pages/gmap/gpsHelper.dart';

class ChannelHelper {
  static const MethodChannel _channel =
      const MethodChannel('com.zpp.sdzx_manage/file');

  static const EventChannel LocationChannel =const 
      EventChannel('com.zpp.sdzx_manage/getName');


  /// 复制文件到
  static Future<String> saveFile(String file) async {
    assert(file != null);
    final result = await _channel.invokeMethod('saveFileToGallery', file);
    //print(result);
    return result;
  }

  //发布广播
  static Future sendCast(String file) async {
    assert(file != null);
    final result = await _channel.invokeMethod('sendCast', file);
    return result;
  }

 static Future showToast(String content) async {
    assert(content != null);
    final result = await _channel.invokeMethod('showToast', content);
    return result;
  }

//获取系统外部的存储目录
  static Future getFileDir() async {
    final result = await _channel.invokeMethod('getFileDir');
    return result;
  }

  static Future getLocation() async {
   
    final result = await _channel.invokeMethod('getLocation');
    
    return result;
  }

 static Future getLocation2() async {
   
    final result = await _channel.invokeMethod('getLocation');
    var loc=GMapHelper.getLocation(result);
    var loc2=GpsHelper.transform(loc.latitude, loc.longitude);
    return loc2;
  }

  
}
